<template>
  <div>
      <page-tab-list
      url="/ChsDangerNotPorduce/GetPageData"
      :params="params"
      @initActive="_initActive"
      @initList="_initList"
      ref="PageTabList"
    >
    <div v-if="this.active === 0">
         <van-cell
        class="card"
        @click="openDetail(item)"
        v-for="(item, index) in list"
        :key="index"
      >
        <div>
          <div>
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_list_enterprise.png"
                />公司：{{ item.EnterpriseName }}
              </van-col>
            </van-row>
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_list_view.png"
                />状态：{{ item.StatusName }}
              </van-col>
            </van-row>
           
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_list_user.png"
                />改派部门：{{ item.CorrectiveDeptName }}
              </van-col>
            </van-row>
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_list_date.png"
                />录入时间：{{ item.CreateDate }}
              </van-col>
            </van-row>
            
            <!-- <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_company_check.png"
                />隐患描述：{{ item.HiddenDangerDesc }}
              </van-col>
            </van-row> -->

            <van-row>
              <van-col span="24">
                <div class="dep_btm">
                  <div
                    class="btm_item"
                    v-if="item.Status == '60'"
                    @click.stop="openEdit(item.TaskId)"
                  >
                    <img
                      src="@/assets/Images/AppIcon/icon_list_edit.png"
                      alt=""
                    />
                    <div class="mr-10">编辑</div>
                  </div>

                  <div
                    class="btm_item"
                    v-if="item.Status == '60'"
                    @click.stop="SubmitReassignment(item)"
                  >
                    <img
                      src="@/assets/Images/AppIcon/icon_list_verify.png"
                      alt=""
                    />
                    <div class="mr-10">改派</div>
                  </div>

                  <div
                    class="btm_item"
                    @click.stop="delData(item)"
                    v-if="item.Status == '60'"
                    style="margin-right: 15px"
                  >
                    <img src="@/assets/Images/AppIcon/icon_delete.png" alt="" />
                    <div>删除</div>
                  </div>

                </div>
              </van-col>
            </van-row>
          </div>
        </div>
      </van-cell>
    </div>
    <div v-if="this.active === 1">
         <van-cell
        class="card"
        @click="openDetail(item)"
        v-for="(item, index) in list"
        :key="index"
      >
        <div>
          <div>
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_list_enterprise.png"
                />公司：{{ item.EnterpriseName }}
              </van-col>
            </van-row>
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_list_view.png"
                />状态：{{ item.StatusName }}
              </van-col>
            </van-row>
           
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_list_user.png"
                />改派部门：{{ item.CorrectiveDeptName }}
              </van-col>
            </van-row>
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_list_date.png"
                />录入时间：{{ item.CreateDate }}
              </van-col>
            </van-row>
            <!-- <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_company_check.png"
                />隐患描述：{{ item.HiddenDangerDesc }}
              </van-col>
            </van-row> -->
            <van-row>
              <van-col span="24">
                <div class="dep_btm">
                  <!-- 推派按钮 -->
                 <div
                    class="btm_item"
                    @click.stop="PushfactionTask(item)"
                    v-if="item.Status == '70'"
                    style="margin-right: 15px" 
                  >
                    <img src="@/assets/Images/AppIcon/icon_exam_add.png" 
                    alt="" />
                    <div>指派</div>
                  </div>

                  <!-- 退回按钮 -->
                  <div
                    class="btm_item"
                    @click.stop="TaskReturn(item)"
                    v-if="item.Status == '70'"
                    style="margin-right: 15px" 
                  >
                    <img src="@/assets/Images/AppIcon/icon_list_distribution.png" 
                    alt="" />
                    <div class="mr-10">退回</div>
                  </div>
                </div>
              </van-col>
            </van-row>
          </div>
        </div>
      </van-cell>
    </div>
    </page-tab-list>
  </div>
</template>

<script>
import PageTabList from "@/components/PageTabList/PageTabList.vue";
import { getMenuByMenuCode } from "@/api/common";

export default {

  components: { PageTabList },

  data() {
    
    return {
      rightValue: 0,
      active: 0,
      list:[],
      params: [
         {
          title:"待改派",
          dataType: "string",
          type : "correctiveList_dgp"
        },
        {
          title:"待指派",
          dataType: "string",
           type : "correctiveList_dzp"
        },
      ],
    };
    
  },

  created() {
    this.getMenuByMenuCode();
  },

  methods: {
    _initActive(active) {
      this.active = active;
    },
    _initList(list) {
      this.list = list;
    },

    // 详情
    openDetail(item) {
      this.$router.push({
        path: "/FeedSafetyProduction/Detail",
        query: { 
          id: item.ID,
          TaskId : item.TaskId
         },
      });
    },


    // 提交
    SubmitReassignment(item) {
      this.$router.push({
          path:'/FeedSafetyProduction/examineApprove',
          query: { id: item.ID },
        })
    },

    // 删除任务
    delData(item) {
      this.$dialog
        .confirm({
          title: "询问",
          message: "您确定要删除该条记录吗？",
        })
        .then(() => {
          let params = { id: item.ID };
          this.$axios
          // GET /api/ChsDangerNotPorduce/Delete/{id}
            .get('/ChsDangerNotPorduce/Delete/{id}', {
              params: params,
            })
            .then((res) => {
              this.$toast("删除成功");
              this.$refs.PageTabList.refreshList();
            });
        })
    },

    // 编辑
    openEdit(TaskId) {
      // GET /api/ChsDangerNotPorduce/Edit/{id}
      this.$router.push({
        path: "/FeedSafetyProduction/Edit",
        query: { TaskId : TaskId},
      });
      return true;
    },

    // 任务退回
    TaskReturn(item) {
      this.$dialog
        .confirm({
          title: "询问",
          message: "您确定要退回该条记录吗？",
        })
        .then(() => {
          let params = { id: item.ID };
          this.$axios
            .get('/ChsDangerNotPorduce/ExitDept', {
              params: params,
            })
            .then((res) => {
              this.$toast("退回成功");
              this.$refs.PageTabList.refreshList();
            });
        })
    },
    // 推派任务
    PushfactionTask(item) {
        this.$router.push({
          path:'/FeedSafetyProduction/PushfactionTask',
          query: { TaskId : item.TaskId },
        })
    },
    getMenuByMenuCode() {
        var me = this;
        getMenuByMenuCode("GxInterviewRecord_List").then((res) => {
          me.rightValue = res.data ? res.data.RoleRightValue : 0;
        });
      },

    },
};
</script>
<style lang="less" scoped>
.all_dep {
  background-color: #ffffff;
}

.warn_header {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin-bottom: 10px;
  .warn_tag {
    position: absolute;
    right: 0;
    top: 0;
    border-radius: 26.64rem 0 0 26.64rem;
  }
}
.dep_sort {
  // display: flex;
  // flex-wrap: wrap;
  // margin-bottom: 5px;
  img {
    height: 15px;
    width: 15px;
    margin-right: 5px;
  }
}
.dep_btm {
  display: flex;
  justify-content: flex-end;
  .btm_item {
    display: flex;
    align-items: center;
    img {
      height: 15px;
      width: 15px;
      margin-right: 5px;
    }
  }
}

</style>
